﻿@{
    ViewBag.Title = "Project-Student Report";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    Project-Student Report</h2>
<form action="" method="post" id="form" name="formProject">
<input type="hidden" id="Action" name="Action" />
<div class="clear">
</div>
<!-- End .clear -->
<!-- Search -->
<div class="content-box" id="Search">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3 id="toggleSearch">
            Report</h3>
        <div class="clear">
        </div>
    </div>
    <!-- End .content-box-header -->
    <div class="content-box-content">
        @{ if (TempData["Message"] != null)
               {
                <div class="notification attention png_bg">
                    <a href="#" class="close">
                        <img src="../../Content/images/icons/cross_grey_small.png" title="Close this notification"
                            alt="close" /></a>
                    <div>
                        @TempData["Message"].ToString()
                    </div>
                </div>
               }
            }
        <fieldset>
            <div class="childCol">
               
                <p>
                    <label class="width12 floatLeft">
                        Deparment:</label>
                    @Html.DropDownList("DepartmentID", (SelectList)ViewData["DepartmentList"], new { @class = "width20 input-inline" })
                </p>
                  <p>
                    <label class="width12 floatLeft">
                        Semester:</label>
                    @Html.DropDownList("SemesterID", (SelectList)ViewData["SemesterList"], new { @class = "width20 input-inline" })
                </p>
            </div>
            <div class="childCol">
              
                <p>
                    <label class="width12 floatLeft">
                        Subject:</label>
                    @Html.DropDownList("SubjectID", (SelectList)ViewData["SubjectList"], new { @class = "width20 input-inline" })
                </p>
            </div>
            <br clear="all" />
            <p>
                <input type="button" class="button"  id="btnWord" value="Export to Word" />
                <input type="button" class="button"  id="btnPDF" value="Export to PDF" />
            </p>
        </fieldset>
    </div>
</div>
</form>
<script language="javascript" type="text/javascript">
    $("#StReport").addClass("current");
    $("#Report").addClass("current");




    $("#DepartmentID").change(function () {
        if ($(this).val() != null) {
            var DepartmentID = $("option:selected", this).val();
            $.post('@Url.Action("GetSubjectByDepartmentID", "Project")', { ID: DepartmentID }, function (data) {
                if (data != null) {
                    //Invoice To
                    var options = $("#SubjectID").attr('options');
                    $("#SubjectID").children().remove();
                    $.each(data.ListSubject, function (index, Subject) {
                        var option = new Option(Subject.SubjectName, Subject.SubjectID);
                        options[options.length] = option;
                    });
                }
            });
        }
    });

    $("#SubjectID").change(function () {
        if ($(this).val() != null) {
            var SubjectID = $("option:selected", this).val();
            $.post('@Url.Action("GetProjectBySubjectID", "Project")', { ID: SubjectID }, function (data) {
                if (data != null) {
                    //Invoice To
                    var options = $("#ProjectID").attr('options');
                    $("#ProjectID").children().remove();
                    $.each(data.ListProject, function (index, Project) {
                        var option = new Option(Project.ProjectName, Project.ProjecttID);
                        options[options.length] = option;
                    });
                }
            });
        }
    });

    $("#btnWord").click(function () {
        var semester = $("#SemesterID").val();
        if (semester <= 0) {
            jAlert("Please, Select Semester!");
            return;
        }
        $("#Action").val("Word");
        $('form').submit();
    });

    $("#btnPDF").click(function () {
        var semester = $("#SemesterID").val();
        if (semester <= 0) {
            jAlert("Please, Select Semester!");
            return;
        }
        $("#Action").val("PDF");
        $('form').submit();
    });

</script>
